<?php 
namespace app\common\model;
use think\Model;

class Revert extends Model
{
	protected $table = 'revert';
	protected $pk = 'revert_id';
	protected $autoWriteTimestamp = true;
	protected $createTime = 'revert_create_time'; 
	protected $updateTime = 'revert_update_time';



	  // 运营后台归还地点列表
    public static function showlist($pagesize) 
    {
        $where['revert_is_delete'] = ['eq', 0];

        $keyword = input('param.keyword');
        $where['a.revent_tel|a.revent_receiver_name|c.store_name|revent_detailed_address'] = ['like', "%$keyword%"];
 
        $data = Revert::alias('a')
                -> field('a.revert_id,a.revent_receiver_name,a.revent_tel,a.revent_detailed_address,c.store_id,c.store_name')
                -> join('merchant b', 'a.revert_merchant_id=b.merchant_id', 'left')
                -> join('store c', 'b.merchant_id=c.store_merchant_id', 'left')
                -> where($where)
                -> order('a.revert_id', 'desc')
                -> paginate($pagesize);


        return $data;
    } 
   

    // 运营后台查看归还地点
    public static function getSince($revertId)
    {
        $data = Revert::find($revertId);
        return $data;
    } 

    // 运营后台删除归还地点
    public static function changeDel($id)
    {
        $result = Revert::where('revert_id', $id)->setField('revert_is_delete', 1);
        if(!$result)
            return false;

        return true;
    } 
} 